473,442 Members | 4,793 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

generate tabs dynamically using ajax

Hi friends, i am using ajax in asp.net.

i am using tab container, tab panel controls.

i want to add tab panel control dynamically on button click.


i form code is:


Expand|Select|Wrap|Line Numbers
  1. <%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>
  2.  
  3. <%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
  4.     Namespace="System.Web.UI" TagPrefix="asp" %>
  5. <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
  6.  
  7. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  8.  
  9. <html xmlns="http://www.w3.org/1999/xhtml" >
  10. <head runat="server">
  11.     <title>Untitled Page</title>
  12. </head>
  13. <body>
  14.     <form id="form1" runat="server">
  15.     <div>
  16.         &nbsp;</div>
  17.       <asp:ScriptManager ID="ScriptManager1" runat="server">
  18.         </asp:ScriptManager>
  19.         <cc1:TabContainer ID="TabContainer1" runat="server" Width="600">
  20.             <cc1:TabPanel ID="TabPanel1" runat="server" HeaderText="tab1">
  21.              <ContentTemplate>
  22.                     <asp:Button ID="asd" runat="server" Width="30" />
  23.                 </ContentTemplate>
  24.             </cc1:TabPanel>
  25.             <cc1:TabPanel ID="TabPanel2" runat="server" HeaderText="tab2">
  26.             </cc1:TabPanel>
  27.  
  28.         </cc1:TabContainer>
  29.         <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
  30.  
  31.     </form>
  32. </body>
  33. </html>

my page code is:

Expand|Select|Wrap|Line Numbers
  1. public partial class _Default : System.Web.UI.Page 
  2. {
  3.     int i = 0;
  4.     AjaxControlToolkit.TabPanel tp;
  5.  
  6.     protected void Page_Load(object sender, EventArgs e)
  7.     {
  8.  
  9.     }
  10.     protected void Button1_Click(object sender, EventArgs e)
  11.     {
  12.         i = i + 1;
  13.         tp = new AjaxControlToolkit.TabPanel();
  14.         tp.ID = "tp" + i.ToString();
  15.         Button b = new Button();
  16.         b.ID = "b" + i.ToString();
  17.         tp.Controls.Add(b);
  18.         tp.HeaderText = "i am new" + i.ToString();
  19.         TabContainer1.Controls.Add(tp);
  20.     }
  21. }


i am able to add one dynamic tab when i click the button first time. But when i click the button for the second time, i am getting error.

"Specified argument was out of the range of valid values.
Parameter name: index "


any help?

thank you.
Nov 28 '08 #1
5 8294
acoder
16,027 Expert Mod 8TB
As a full member now, you should know that we expect your code to be posted in [code] tags (See How to Ask a Question).

This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

You have been told nicely before, but the advice has fallen on deaf ears it seems. Regard this as a warning. Further violations may lead to a temporary an your account which I'm sure you'll want to avoid.

Please use the tags in future.

Moderator
Nov 28 '08 #2
i do follow the rules from now.

Indeed, yes i forgotten to add them.
i wont repeat it again.

Thank you

@acoder
Nov 28 '08 #3
acoder
16,027 Expert Mod 8TB
@ravindarjobs
That doesn't seem like a JavaScript error. It seems like a .NET one. Can you post the client-side version of your code.
Nov 28 '08 #4
yes it is .net using ajax.

this link has helped me

Siderite Zackwehdex's Blog: Fixing TabContainer to work with dynamic TabPanels
Nov 28 '08 #5
acoder
16,027 Expert Mod 8TB
Glad you got it working and thanks for posting the solution :)
Nov 28 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: k.mitz | last post by:
Hi, I have a PHP application that allows users to generate a .pdf report of their database content. Normally, I've had to refresh a page to call the script to generate the report, so there's a...
12
by: nat | last post by:
Hi all, I was going to post this in the AJAX forum, but apparently someone posted an AJAX/C# question in there today and was told to try this forum instead. So here goes: I'm trying to figure...
135
by: Xah Lee | last post by:
Tabs versus Spaces in Source Code Xah Lee, 2006-05-13 In coding a computer program, there's often the choices of tabs or spaces for code indentation. There is a large amount of confusion about...
5
by: sean.gilbertson | last post by:
Hi, I'm sort of new to ASP.NET 2.0 and ASP.NET in general. I have some data that I would like to display in a tabular format, but I'm going to be generating the columns dynamically, and I would...
9
by: pbd22 | last post by:
Hi. I am building a bit of a "learn-as-you-go" web site. I have tabs that change based on what page the user is on. The problem is, I have been using a javascript doOnLoad function to recognize...
1
by: jianxin9 | last post by:
Hi, I have an ajax powered tabs box that has a javascript drop-down search menu in the first tab. When I click on another tab, and go back to the first tab I have to refresh the page to get the...
3
by: samikrc | last post by:
Hello, I have an accordion (using the Rico framework at www.openrico.org) and each tab of the accordion is basically some sort of wizard (having a description and a 'Start' button in each tab). When...
7
by: Nathan Sokalski | last post by:
I have a page which I dynamically add several usercontrols (*.ascx files) to using the following code: Public Sub Refresh() For Each section As DataRow In Me.GetSections().Rows...
2
by: =?Utf-8?B?aUhhdkFRdWVzdGlvbg==?= | last post by:
I have a dropdown with the list of items from 1 to 6 Below the dropdown there is a table(This table contains all textbox and dropdownlist) with 6 rows and 5 cloums, which is INVISIBLE by default. ...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.